package test;

public class SellTicket  implements Runnable{

    private  int tickets=100;

    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        while (tickets>0){
            System.out.println(name+"窗口售出的一张票，余票"+ --tickets);
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        Runnable sellTicket=new SellTicket();
        Thread a=new Thread(sellTicket,"A");
        Thread b=new Thread(sellTicket,"B");
        Thread c=new Thread(sellTicket,"C");
        Thread d=new Thread(sellTicket,"D");
        a.start();
        b.start();
        c.start();
        d.start();
    }
}
